<template>
<view class="container">
  <!-- 头部 -->
  <view class="header">
    <view class="logo">
      <text class="logo-text">竞享空间</text>
    </view>
  </view>
  
  <!-- 教练登录卡片 -->
  <view class="login-card">
    <text class="login-title">教练登录</text>
    
    <!-- 教练名输入框 -->
    <view class="input-group">
      <text class="input-label">请输入教练名</text>
      <view class="input-field">
        <input
          v-model="coach.name"
          type="text"
          placeholder="请输入您的教练名"
          class="input"
        />
      </view>
    </view>

    <!-- 密码输入框 -->
    <view class="input-group">
      <text class="input-label">请输入密码</text>
      <view class="input-field">
        <input
          v-model="coach.password"
          type="password"
          placeholder="请输入您的密码"
          class="input"
        />
      </view>
    </view>

    <!-- 登录按钮 -->
    <button class="login-btn" @click="Login">登录</button>

    <!-- 其他操作 -->
    <view class="links">
      <text class="link">注册账号</text>
      <text class="link">忘记密码？</text>
    </view>
  </view>
  
  <!-- 底部 -->
  <view class="footer">
    <text>© 2023 竞享空间 版权所有</text>
  </view>
</view>
</template>

<script setup>
import { login } from '@/api/login.js'
	
import { onMounted, ref } from "vue";
const coach = ref({
  "name": "",
  "password": ""
})
//测试区开始

onMounted(() => {
	let tepCoach = uni.getStorageSync("coach")
	if(tepCoach){
		coach.value = tepCoach
		Login()
	}
})

const Login = () =>{
	login(coach.value).then(res => {
		console.log("登录成功获取的的{}",res.data)
		uni.setStorageSync("coachId",res.data)
		uni.setStorageSync("coach",coach.value)
		uni.redirectTo({
		  url: "/pages/index/index"
		})
	})
}
//测试区结尾
</script>

<style scoped>
.container {
  display: flex;
  flex-direction: column;
  padding: 40rpx;
  min-height: 100vh;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 60rpx;
}

.logo {
  color: #ff7e5f;
}

.logo-text {
  font-size: 36rpx;
  font-weight: bold;
}

.switch-coach {
  font-size: 28rpx;
  color: #ff7e5f;
  transition: all 0.3s;
  padding: 12rpx 24rpx;
  border: 1rpx solid #ff7e5f;
  border-radius: 20rpx;
}

.switch-coach:active {
  transform: translateY(-4rpx);
  background-color: rgba(255, 126, 95, 0.1);
}

.login-card {
  background: white;
  border-radius: 32rpx;
  padding: 60rpx;
  box-shadow: 0 10rpx 25rpx rgba(0, 0, 0, 0.05);
  transition: transform 0.3s, box-shadow 0.3s;
  border: 1rpx solid #eee;
  margin-bottom: 60rpx;
}

.login-card:active {
  transform: translateY(-10rpx);
  box-shadow: 0 15rpx 30rpx rgba(0, 0, 0, 0.1);
}

.login-title {
  font-size: 48rpx;
  font-weight: 600;
  margin-bottom: 60rpx;
  color: #333;
  text-align: center;
}

.input-group {
  margin-bottom: 40rpx;
}

.input-label {
  display: block;
  margin-bottom: 16rpx;
  font-size: 28rpx;
  color: #555;
  font-weight: 500;
}

.input-field {
  position: relative;
  display: flex;
  align-items: center;
}

.input {
  width: 100%;
  padding: 30rpx;
  border: 1rpx solid #ddd;
  border-radius: 16rpx;
  font-size: 32rpx;
  transition: all 0.3s;
  background-color: #f8f9fa;
}

.input:focus {
  border-color: #ff7e5f;
  box-shadow: 0 0 0 4rpx rgba(255, 126, 95, 0.2);
  outline: none;
  background-color: white;
}

.login-btn {
  width: 100%;
  padding: 30rpx;
  background: #ff7e5f;
  color: white;
  border: none;
  border-radius: 16rpx;
  font-size: 32rpx;
  font-weight: 600;
  transition: all 0.3s;
  margin-top: 20rpx;
}

.login-btn:active {
  background: #ff6b4a;
  transform: translateY(-4rpx);
  box-shadow: 0 10rpx 30rpx rgba(255, 126, 95, 0.4);
}

.links {
  display: flex;
  justify-content: space-between;
  margin-top: 40rpx;
}

.link {
  color: #ff7e5f;
  font-size: 28rpx;
  transition: all 0.3s;
  padding: 8rpx 16rpx;
  border-radius: 8rpx;
}

.link:active {
  color: #ff6b4a;
  background-color: rgba(255, 126, 95, 0.1);
}

.footer {
  text-align: center;
  color: #777;
  font-size: 28rpx;
  margin-top: auto;
  padding-top: 40rpx;
}

/* 响应式设计 */
@media (max-width: 480px) {
  .container {
    padding: 20rpx;
  }
  
  .login-card {
    padding: 40rpx;
  }
  
  .header {
    flex-direction: column;
    text-align: center;
  }
  
  .switch-coach {
    margin-top: 20rpx;
  }
}
</style>